package Thread.Thread_State;

/**
 * 三种阻塞状态
 */
public class BlockedState {
    public static void main(String[] args) {
        Object lock=new Object();
        Thread t1=new Thread(()->{
           synchronized (lock){
               while (true){
                   try {
                       //TIME_WAITING 等待时间到了自动唤醒
//                       Thread.sleep(1000);
                       //线程等待
                       lock.wait();
                   } catch (InterruptedException e) {
                       throw new RuntimeException(e);
                   }
               }
           }
        },"t1线程~~");
        t1.start();
        Thread t2=new Thread(()->{
            synchronized (lock){
                //BLOCKED 等待获取锁对象
                System.out.println("哈哈哈哈~~~");
            }
        },"t2线程~~");
        t2.start();
    }
}
